package com.turing.common.util;

import java.lang.reflect.Field;
import java.util.List;

/**
 * @Description TODO
 * @Author lcy
 * @Date 2021/7/20 15:25
 */
public class ExampleUtil {


    /**
     * 复制example的对象
     *
     * @param source 源对象
     * @param target 目标对象
     * @author lcy
     * @date 2021/7/20 15:25
     **/
    public static <T> void copyCondition(T source, T target) {
        if (null != source && null != target) {
            try {
                Field field = source.getClass().getSuperclass().getDeclaredField("criteria");
                field.setAccessible(true);

                List sourceCriteria = (List) field.get(source);
                List targetCriteria = (List) field.get(target);

                targetCriteria.addAll(sourceCriteria);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
